const express = require('express')
const router = express.Router()
const { ProjectController } = require('../controller/project')
const authMiddleware = require('../middleware/auth')
const multer = require('multer')
const storge = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, 'public/img')
  },
  filename: function (req, file, cb) {
    var fileformat = (file.originalname).split('.');
    cb(null, file.fieldname + '-' + Date.now() + '.' + fileformat[fileformat.length - 1]);
  }
})
const upload = multer({ storage: storge })
router.post('/v1/dataPicture/upload', authMiddleware, upload.single('file'), ProjectController.dataPNGUpload)
router.post('/v1/project/add', authMiddleware, ProjectController.projectAdd)
router.put('/v1/project/edit', authMiddleware, ProjectController.projectUpd)
router.delete('/v1/project/del', authMiddleware, ProjectController.projectDel)
router.get('/v1/project/list', authMiddleware, ProjectController.projectList)
router.post('/v1/project/copy', authMiddleware, ProjectController.projectCopy)
module.exports = router
